<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      class Animal {
        constructor(name, age) {
          this.name = name
          this.age = age
        }

        eat(food) {
          console.log(`${this.name}  吃 ${food}`)
        }
      }

      class Dog extends Animal {
        constructor(name, age, price) {
          // 调用父类的构造器
          super(name, age)

          this.price = price
        }

        eat(food, girl) {
          console.log(`${this.name}  吃 ${food} ，并且身边有 ${girl} 作伴`)
        }
      }

      /**
       * 继承的好处，不光可以拿过来用，还可以发扬光大（拓展、覆盖、重写...）
       */

      const d1 = new Dog('冈瑟四世', 5, 24000000000)
      //   d1.price = 24000000000
      //   console.log(d1)

      //   d1.eat('牛排')
      d1.eat('鱼子酱', '麦当娜')
    </script>
  </body>
</html>
